#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, p, n;
  string a;
  cin >> n;
  cin >> a;
  int sum = 0, sum1 = 0, f = 0;
  for (j = 0; j < n / 2; j++) {
    sum += (a[j] - '0');
    sum1 += (a[n - 1 - j] - '0');
    if ((a[j] != '4' && a[j] != '7') ||
        (a[n - 1 - j] != '4' && a[n - 1 - j] != '7')) {
      f = -1;
      break;
    }
  }
  if (sum == sum1 && f == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
