#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e18;
const long long minN = -1e18;
const long long MOD = 1e9 + 7;
const long long MOD1 = 998244353;
const int bignumlen = 2200;
const int Blen = 8;
const long long base = 100000000;
const int baseHash = 31;
const long double PI = acos(-1);
const long long limit = 2e5 + 5;
const long long limit1 = 1e6 + 5;
long long n;
string s;
long long sum1 = 0, sum2 = 0;
void solveProblem() {
  for (int i = (0); i < (n / 2); ++i) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO" << '\n';
      return;
    } else
      sum1 += s[i] - '0';
  }
  for (int i = (n / 2); i < (n); ++i) {
    if (s[i] != '4' && s[i] != '7') {
      cout << "NO" << '\n';
      return;
    } else
      sum2 += s[i] - '0';
  }
  if (sum1 == sum2)
    cout << "YES";
  else
    cout << "NO";
}
void fastInput() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void readInput() {
  cin >> n;
  cin >> s;
}
int main() {
  fastInput();
  readInput();
  solveProblem();
}
